PutMessage('Please select an area of interest in the Camera window.');
exit;
end;
nFrames:=GetNumber('Number of frames:',4);
StartCapturing;
Camera:=nPics;
n:=0;
repeat
if Button then begin
MakeRoi(left,top,width,height);
n:=n+1;
Duplicate('Frame ',n:1);
SelectPic(Camera);
StartCapturing;
end;
until n=nFrames;
StopCapturing;
Dispose;
SetOption; TileWindows;
end;
macro 'Draw Histogram';
var
max,scale:real;
i,margin,width,height:integer;
begin
Margin:=10;
width:=256;
height:=0.6*256;
Measure;
SetForegroundColor(255);
SetBackgroundColor(0);
SetLineWidth(1);
SetNewSize(width+2*margin,height+2*margin);
MakeNewWindow('Histogram');
MakeRoi(margin,margin-1,width,height+1);
DrawBoundary;
max:=0;
for i:=1 to 254 do
if histogram[i]> max then max:=histogram[i];
scale:=height/max;
for i:=1 to 254 do begin
MakeRoi(margin+i,margin,1,histogram[i]*scale);
SetForegroundColor(i);
fill;
end;
SelectAll;
FlipVertical;
KillRoi;
end;
macro 'Use Even Field';
{
Replaces every odd scan line with its neighboring even scan line. Can be used to improve the quality of images that have even and odd fields that are out of sync as the result of subject movement during capture. Due to a bug in PutRow(fixed in V1.34), you must force a screen update by double-click on the magnifying glass to see the result.
}
var
i,width,height,row:integer;
begin
GetPicSize(width,height);
row:=0;
for i:=0 to height/2 do begin
GetRow(0,row,width);
PutRow(0,row+1,width);
row:=row+2;
end;
end;
macro 'Open and transfer selection [O]';
begin
if nPics>0 then KillRoi; {Save Selection}
Open(''); {Prompt for file name}
RestoreROI; {Transfer selection to new window}
end;
macro 'Subtract Background';
var
i,Corrected:integer;
begin
SelectAll;
Duplicate('Background Corrected');
Corrected:=PicNumber;
Duplicate('Background');
ScaleSelection(.25,.25);
RestoreRoi;
for i:=1 to 10 do begin
SetOption; Smooth;
end;
ScaleSelection(4,4);
SelectAll;
Copy;
SelectPic(Corrected);
Paste;
Subtract;
ResetGrayMap;
end;
macro 'ASCII Dump';
{
Generates an alphanumeric listing of pixels values starting at
the upper left corner of the current selection. 20 rows and 44 columns
can be displayed with the default 552 x 436 window. The size of the window
used to display the pixel values is determined by New Width and
PutMessage('This macro requires a rectangular selection');
exit;
end;
SetForegroundColor(255);
SetBackgroundColor(0);
MakeNewWindow('ASCII Dump');
dump:=PicNumber;
GetPicSize(width,height);
MaxWidth:=width div 24 - 2;
MaxHeight:=height div 9 - 3;
if roiWidth>MaxWidth then roiWidth:=MaxWidth;
if roiHeight>MaxHeight then roiHeight:=MaxHeight;
SetFont('Monaco');
SetFontSize(9);
SetText('No background; Left Justified');
MoveTo(2,12);
write(' ');
for h:=roiLeft to roiLeft+roiWidth-1 do write(h:4);
writeln;
writeln;
for v:=roiTop to roiTop+roiHeight-1 do begin
write(v:3,' ');
for h:=roiLeft to roiLeft+roiWidth-1 do begin
ChoosePic(image);
value:=GetPixel(h,v);
ChoosePic(dump);
write(value:4);
end;
writeln;
end;
ChoosePic(image);
end;
macro 'Resize All';
{
Resizes and/or rotates all currently open widows. For example,
change the ScaleAndRotate command below to
ScaleAndRotate(2,2,0) to change the size of all the images
in a movie loop sequence from 128 x 128 to 256 x 256.
}
var
i:integer;
begin
SetScaling('Bilinear; Create New Window');
for i:=1 to nPics do begin
ChoosePic(1);
ScaleAndRotate(1.9,1.9,0);
ChoosePic(1);
Close;
end;
for i:=1 to nPics do begin
ChoosePic(i);
SetPicName(i);
end;
end;
macro 'Dispose All';
begin
DisposeAll;
end;
macro 'Save All';
{
Saves all currently open images in a folder using '0001', '0002', etc.
as the file names. The save file dialog box will be displayed once
so that you can specify the folder to save the files in.
}
var
n:integer;
begin
for n:=1 to nPics do begin
SelectPic(n);
SetPicName(n:2);
SaveAs;
{Export;}
end;
end;
macro 'Make Movie to Disk';
{
}
var
nFrames,n,Left,Top,Width,Height:integer;
Delay:real;
isRoi:boolean;
begin
GetRoi(Left,Top,Width,Height);
isRoi:=width>0;
nFrames:=GetNumber('Number of Frames?',10);
delay:=GetNumber('Delay Between Frames(seconds)?',60);
for n:=1 to nFrames do begin
Capture;
if isRoi then MakeRoi(Left,Top,Width,Height);
SetPicName('Frame ',n);
SaveAs;
Wait(delay);
end;
end;
macro 'Import FITS';
{
This is an example of how to decode an image file header. In this case, the header is 2880 bytes long and bytes 266-269 contain the width(ASCII) and bytes
246-249 cantain the height. Refer to "FITS:A Flexible Image Transport System",
Astronomy and Astrophysics Supplement Series 44, 1981, 363-370.
}
var
width,height,offset,i,d,m:integer;
begin
width:=512;
height:=1;
offset:=0;
SetImport('8-bit');
SetCustom(width,height,offset);
Import(''); {Read in header as an image, prompting for the file name.}
if not ((GetPixel(108,0)=49) and (GetPixel(109,0)=54)) then begin
{BITPIX<>16}
PutMessage('This macro only reads 16-bit FITS files');
Dispose(nPics);
exit;
end;
m:=1000;
width:=0;
for i:=266 to 269 do begin
d:=GetPixel(i,0);
if d=32 then d:=48;
d:=d-48;
width:=width+d*m;
m:=m/10;
end;
m:=1000;
height:=0;
for i:=346 to 349 do begin
d:=GetPixel(i,0);
if d=32 then d:=48;
d:=d-48;
height:=height+d*m;
m:=m/10;
end;
Dispose(nPics); {The ID of the last window opened is equal to nPics.}
offset:=2880;
SetImport('16-bit Signed; Calibrate; Autoscale');
SetCustom(width,height,offset);
Import(''); {No prompt this time; Import remembers the name.}
FlipVertical;
end;
macro 'Average two Images';
{Generates the arithmetic average of two images.}
begin
if nPics<>2 then begin
PutMessage('This macro requires exactly two image windows to be open.');
Exit;
End;
ScaleMath(false);
MultiplyByConstant(0.5);
NextWindow;
MultiplyByConstant(0.5);
SelectAll;
Copy;
NextWindow;
Paste;
Add;
end;
macro 'Make Montage [M]';
{Opens a new window and creates in it a composite image made from all}
{currently open images. All the images must be the same size.}